Skip to main content

Full text of "doctor-dobbs-journal-ddj-232-july-1995"

See other formats





■ BSP FOR 3-D 






•• . m You navigate along a thin line to keep your team on track. Fortunately, 
for C++ developers creating applications for Windows* 95. Microsoft® has 
a core set of products designed to ensure they continue moving ahead. 

Microsoft' Visual C++ 'development system provides a powerful, 
tightly integrated tool set. including the Microsoft Foundation Class Library: 
70.000 lines of pre-built. pre-tested code to give you a head start. With a 
Visual C++ Subscription, three times a year you’re updated on the 
HIM latest tools and technologies, including new features for Windows 95 
* '' development. That way. you'll get applications up, and running 
H| quickly, and Windows 95 ready. Microsoft SourceSafe'" and 
DrM Microsoft Test keep your team on course. SourceSafe's project ' 
oriented approach to source code control promotes code reuse 
Huh and management of multiple releases for development teams of 
glMI any size.Test is an automated testing tool which evaluates applica- 
agTTx tions throughout the development process.Together, they help 

find errors and regressions while identifying where the problems 
occurred. '‘® By joining the Microsoft Developers Network, 

via quarterly CDs, you'll get in-depth technical information, operating sys¬ 
tems and software development kits. Right there on your desktop. More 
importantly, you can get a pre-release version of Windows 95 operating 
system and the SDK. These are just part of our line'of products and 
services designed for your development teams. For more information and 
: the name of your local reseller, call 1-800-719-5577. Dept. NWA. We'll 
even send you a free CD. the Microsoft Roadmap to Developer's Products 
& Services, describing all our tools and programs. That way. you'll have 
everything you need to continue in the only direction you want to go,. 





POET 3.0 







More Piorfofim. More Feolures. More Performoixe. 

irWpt Soil 100, Sot MeM.UtUOt 


What Next, the | 
Kitchen Sink™? 


* y -11--that Microsoft has taken it on 

UK ....— the Stac Electronics settlement, which resulted in Microsoft 

. . coughing up $120 million for infringing on Stac's data*compression patents. Then Microsoft 
ponied up another $90 million to queU Wang Labs’ claims of patent infringement over object 
linking and embedding (OLE) technology. 

Still, the news hasn't been all bad for the world's biggest software producer. Microsoft more 
than made up for any loss of face by throwing a full nelson on Scanrom Publishing, a one-person 
Long Island software publishing house. In naming a CD-ROM that included the Jewish Book of 
Knowledge, excerpts from the Torah, music, cookbooks, and folklore The First Electronic Jewish 
Bookshelf." Scanrom stubbed its toe on a Microsoft trademark claiming ownership of the word 
"bookshelf." Microsoft’s Bookshelf, you recall, is a collection of standard reference materials, 
including a dictionary, thesaurus, world almanac, encyclopedia, ZIP-code directory, and the like. 

Amazingly, Scanrom founder Irving Green wasn't aware of Microsoft’s trademark, which is 
emblazoned all over its packaging. The fust Green heard about it was in February, when he 
received a cease-and-desist letter from Microsoft lawyers— after he'd shipped several thousand CD- 
ROMs. Green estimates it will cost at least $100,000 to change the CD-ROM and its packaging. While 
that's pocket change to Microsoft executives, to Green it’s real money that he simply doesn't haw. 

You’d think that one of Green's options might be to change the name of his CD-ROM to 
something less competitive —"bookcase," for instance. Sorry. Been there, done that, says Allegro 
New Media's Barn' Cinnamon, publisher of CD-ROMs such as the Allegro Reference Series Business 

point, Allegro’s CD-ROM sported the tagline "The ultimate business bookshelf, but 

no can do. How about changing the tag from "bookshelf to "bookcase," countered 
dice, said Microsoft. In other words, say Microsoft lawyers, if you are publishing a 
CD-ROM or any other interactive electronic reference material and you suggest that there’s a book- 
anyihing in your digital doset, expect to receive a registered letter postmarked Redmond. 

Interestingly, the term “lx>okshelf was originally registered in 1987 by Ampro Computers for 

»"computers, computer programs and manuals sold...for use in data base management, word 
processing and data processing." In 1988, Microsoft challenged Ampro's trademark, claiming the 
term "is the common descriptive name for a library, portfolio or collection of books...and 
therefore in the public domain and available for [Microsoft! and other commercial users to use 
fairly to describe their goods." After some haggling, Microsoft ended up buying the rights to the 
•bookshelf moniker from Ampro. I leave it to you to decide if Microsoft has changed its mind 
about whether or not the term is in the public domain and available for others to freely use. 

Green hasn't thrown in the tow-el yet. He’s currently winding his way through Patent and 
Trademark Office OPTO) procedures, filing both a "petition to cancel" Microsoft's trademark claim as 
well as a “notice of opposition" to recent changes Microsoft has proposed to the terms of the claim. 
Green points out that lire original Ampro trademark, which Microsoft has relied upon for the past 
few years, applied to computer hardware. Only recently has Microsoft moved to diange the 
definition of the trademark to cover computer software that contains a collection of interactive works. 

It’s little wonder that Microsoft is roughing up Scanrom. It’s called "precedence," particularly 
when there are bigger fish to fry. This includes IBM, which produces (and sells through 
Counterpoint Publishing) a $99 00 disk-based product called The Health Care Reform Bookshelf 
that provides the text of Clinton’s Health Security Act of 1993, annotations, budget predictions, and 
competing pieces of legislation. Likewise. BusinessWeek magazine presents an interactive electronic 
version of its “Business Bookshelf on America Online. Unless I’ve missed something, Microsoft 
has yet to go after either IBM or McGraw-Hill (publisher of BusinessWeek). By establishing legal 
precedence. Microsoft will have a better chance of taking on those outfits when the time is right. 

When patents are registered, concerned third parties can object. Unfortunately, that's not the case 
with trademarks. To oppose a trademark, a "damaged" party- must file suit against a tradernark 
holder or applicant with the PTO. That action is then heard by a PTO review board, which bases its 
decision on evidence and depositions provided by the involved parties— no juries, no witnesses, 
no Judge Itos. In short, there’s not much you and I can do to protest trademark injustice. 

The lesson to be learned in all of this is to name products carefully. Never take anything for 
granted—even seemingly innocuous terms can be trademarked. (A recent search on the name 
“Bob," for instance, turned up 26 pages of Bob-related trademarks— including one for ‘Bob 
Dylan" and. naturally, another for Microsoft's new interface software. As with "bookshelf," 
Microsoft obtained the rights to “Bob" from another company.) If nothing else, as Irving Green 
w-ould certainly agree, a few hundred dollars for a trademark search is money well spent. 









Only Zinc 

re understand that portinj 
:ode takes 80* of your tin 
amplete portability. 
With Zinc* Application Framework' you can 

Zinc is the only one that delivers 100* portabi 
you'll have your application on other platforms 

Zinc the most productive—and affordable—tot 
programmer can use. 

Productivity that leads to opportunity. 

Portability is just one road you'll find a little 

uct that supplies 100* of the source code. 

It all adds up to productivity. Which means 
more profitability. Which is a concept we prop, 
bly don't have to spell out for you. For free inf 
mation and demonstration software, call toll-fri 
800 638 8665 


Real-Time Graphics Tools for windows ™ 

Program true 16 or 32-bit applications using Rev. 2.0 

Windows 3.1, W 
and Windows N 
SI Supports Borland C/ 

C++, Microsoft/Visual 

Sweep graphs 
Logic graphs 
Scrolling bar graphs 
XY plots 

Dynamic bar graphs 


3 Print to any Windows 
supported printer 

Static Plots 
[3 Line plots 
13 Horizontal and 
vertical bar graphs 
(3 Scatter plots 
(3 Pie charts 
[3 Floating bars 
(3 Group plots 
13 High-low-close plots 
(3 Area plots 
(3 Error bar charts 
(3 Auto axes scaling 
(3 Static data arrays of 
up to 64K points 

13 Zooming 

Delphi Version Now Available! 

Request or download our demo disk! 
Telephone: 6171449-6155 
BBS*: 6171449-4783 

Real-Time Graphics Tools for Windows DLL $600 

Real-Time Graphics Tools for Windows DLL & Source S1200 

VWW: http:llwww.webcom.coml Specify C/C++, Delphi or Visual Basic version when ordering 

-biz-offdquinn-curtislindexMtml 32-bit DLLs onhj avai i able in C / C++ vers i 0 „ 

QuiNN-CURTIS, Inc . 35 HICHLAND CIRCLE . NEEDHAM MA 02194 USA . TEL 617/449-6155 . FAX 617/449-6109 

(continued from page 10) 
munily dial they arc to be studied as phe¬ 
nomena, the way gravity and electro¬ 
dynamics were studied. 

Objectivity, as a style of reasoning, lias 
been studied for millennia. And so has its 
complement: subjectivity. The excitement 

and recognition being showered on Stepanov 
and Lee is well deserted. For within the 

ly differentiated the realm of language as 
subject STUstYle programming I predict, if 
it hasn't already happened by the time you 
receive this letter, will be called “Subject- 
Oriented Programming." Stepanov is right. 
His generic programming is going to launch 
a virtual tidal wave of scientific study and 

understanding of language and its . 

What will happen? If ' 

at PLoP are right, 1 predict the program¬ 
ming community will rediscover both sci¬ 
ence and history. Pattern programming is 
what the authors of the five books of 
Moses were doing in Egypt, while the Chi¬ 
nese authors were w riting The Book of 
Changes and The Book of the Way. 

Stepanov and lee have opened a new 
struggle: Within the science of language, 
there is a complementary relation between 
object and subject. As that mystery un¬ 
folds, programmers will surely turn to Ori¬ 
ental history, where complementary styles 
in structure were studied in great detail. 
We will all be amazed to learn just how 
much our ancestors knew about such sub¬ 
tle phenomena as they occur in nature. 

Dan Palanza 

Corporate disk company 

"The One Stop Shop for Software Developers." 

Diskette and CD-ROM 

B l ® 

On Demand Printing 


Perfect Bound Wire-0 Three Hole Drill Saddlcstiicl 

Custom Packaging & Inserts 

We also offer complete assembly and fulfillment services. 

Nationwide (800) 634-DISK 
(in Illinois 708-616-0700) 


Visit our new internet web site and register on our guest 
list for 10% off your first order with Corporate Disk Co. 


Image Authentication 

Steve Walton's article "Image Authentica¬ 
tion for a Slippery New Age" (.DDJ, April 
1995) poses an interesting question: how 
to prove that a digitized image has not 
been tampered with. Unfortunately, his 

A quick review of his method: Walton 
proposes combining secret, user-generat¬ 
ed keys with checksums of an image. I le 
suggests using the keys as seeds to a 

ing checksum bits around the image in tile 
low-otder bits of selected pixels. 

What would an attack on this system 
look like? To know that an image lias ar¬ 
rived from Walton without alteration, we 
must have communicated keys in advance 
using some trusted channel. In practice, 
unless Walton and his partners want to 
spend all their time generating, transmit¬ 
ting, and safeguarding new keys for every 
image exchanged, drey will end up reusing 
keys, when they do, the system becomes 
vulnerable to a chosen-plaintext attack. 

miliar with the general method (by read¬ 
ing the source in DDf). The problem dren 
becomes recovering tire actual keys. In a 
chosen-plaintext attack, we assume the 
enemy can actually slip images into the 
communication stream, have Walton seal 
them, and compare Ure before and after 
data. The enemy should choose any two 
images with the property that the low- 
order bits of one image are the ones com¬ 
plement of the low-order bits of the oth¬ 
er; for example, where image A has a 1 
in a low-order bit, image B has a 0 low- 
order bit in the comesponding pixel. 

When the enemy compares images A 
and B before and after, all pixels where 
checksum bits are stored can be identified. 
(You need two bit-complementary images 
to recover all bits, sinoe comparison of one 
original image with a sealed version will 
show only the pixels where the checksum 
bit is not equal to the original data bit.) 

Let's say that checksums arc 32 bits, as 
in the original article. Remember that pix¬ 
el locations are chosen by a pseudo¬ 
random number generator. To recover die 
original seed for the generator, and thus 
the key, we need only determine which 
of the 32 pixel locations represents the 
initial state of the generator. Pick a pixel 
position, use it as a seed, and if you can 
tun the generator ahead 31 limes widiout 
generating a number not in the set of check¬ 
sum locations— congratulations, you have 
broken the code. The whole procedure is 
less than a millisecond of computer lime. 

Using multiple keys does not materially 
affect solution time, since each key can be 
solved for independendy. (Walton lias de¬ 
signed the system so that bit locations do 
not overlap between multiple keys; as he 

Dr. Dobb’s Journal, July 1995 



F/\l R CO IX/I ““ST 

corporation a34-a-i8P 

(continued from page 12) 

must since if a key overlaps in one location. 

it will overlap in all subsequent locations.) 

Okay, we can break the system with 
two well-chosen Trojan images. How 
about the easier and more-practical 
-plaintext attack, where an enemy 

Sure. With only one image before-and- 
after to work With, the enemy will not re¬ 
cover all the bits in tire checksum—prob¬ 
ably only half of them. However, he could 
get lucky and recover the first location in 
the sequence (after all. there is a 50/50 
chance); in which case, he is done. If he 
isn't lucky, he needs to determine which 
is the Sist location he does have, and then 
run the pseudo-random number genera¬ 
tor backward from there to recover the 

linear-congrucntiai generator in reverse. 

checksum-and-key method. A better an¬ 
swer to the problem would be to use the 
Secure Hash Algorithm to compute a tong 
060 bits) hash code for an image, and the 
Digital Signature Algorithm to apply it as 
a signature. This has two advantages; SHA 
and DSA are believed to be hard to break, 
public-key scheme such as 

Slav responds: Thanks for your letter, An¬ 
drew. As near as I can tell, you are abso¬ 
lutely correct except that you assume that 
the “enemy" has access to before-and- 
after images. Without these, my statements 
as to security stand. I'll look up your ref¬ 
erences on reversing random-number gen¬ 
erators (if you can do (hat, it solves another 
problem I'm working on) and think a lit¬ 
tle bit more about what you have said. As 
far as incorporating DSA, SHA, RSA, and 

portion, which was left off the published 
version. It would be a good improvement. 
However, my purpose in illustrating the 
techniques of hiding things in noise (“Se¬ 
curity by Obscurity”) was served. 

Network Options 
Dear DDJ, 

William Stallings' article “Congestion Con¬ 
trol in Frame-Relay Networks" (DDJ, Match 
1995) prompted me to write about our ex- 

There's a saying that if you buikl a high¬ 
way, people will drive on it. Texas has 
adapted this idea to information technol¬ 
ogy and found that if you build an infor- 

J/Xf=AISI >o 


Dr. Dobb'sJournal. July 1995 

(continued from page 14) 

mation infrastniccure, people will use it. 

Acconling to the Texas Department of 
Commerce, TEXAS-ONE, a State of Texas- 
lead proposal, lias been awarded $25 mil¬ 
lion in the Federal Technology Reinvest¬ 
ment Project competition. More than 2800 
proposals requesting a total of $8.5 bil¬ 
lion were submitted from companies, 
universities, state and local governments 
nationwide. Tlie Texas Open Network En¬ 
terprise, TEXAS-ONE, will serve small- and 
medium-sized manufacturers in Texas by 
providing an electronic-information net¬ 
work like those previously accessed only 
by large corporations able to afford in¬ 
frastructure investment. TEXAS-ONE is a 
partnership led by the Texas Department 

of Commerce, the Microelectronics and 
Computer Technology System, the Texas 
Department of Information Resources, the 
Texas Innovation Network System. NASA's 
Mid-Continent Technology Transfer Cen¬ 
ter, and the University of Texas at El Paso. 

TEXASONE is a model of what can and 
needs to be accomplished as we grapple 
with the design and implementation of a 
national information superhighway. 

Setting the Revolution Record 

Regarding Jonathan Erickson's "Editorial" 
in the January 1995 issue of DDJ: Actual¬ 

ly, it was the Mark-8 on the cover of the 
July 1974 issue of Radio-Electronics that 
ushered in the personal-computer revo¬ 
lution. The Altair on the cover of Popu¬ 
lar Electronics didn't arrive for another six 
months. By then, the revolution was al¬ 
ready underway. 

Jon Titus 

Milford, Massachusetts 

Flash File Systems 
Dear DDJ, 

Peter Torelli's article. The Microsoft Flash 
File System" ( DDJ February 1995) con¬ 
cluded: “If standards begin to solidify and 
enough resources are devoted to the de¬ 
velopment of other operating-system FFS 
drivers, flash cards could become a dom¬ 
inant form of data exchange for comput- 

Fastest C compiler. 

For Texas Instrument DSPs. 

No assembly required#*' 
Powerful Windows"debugger. 

^ Introducing Tartan C. 


The fact is that flash cards already are 
1 becoming a popular fonn of data exchange 
for computer users because there already 
is a dominant cross-platform standard for 
flash cards called the "PC Card ATA Stan¬ 
dard " It was developed by PCMCIA. Many 
large vendors, including Hewlett-Packard. 
IBM, Casio, Fujitsu, Motorola, 3M, and Ver¬ 
batim. market ATA cards because they are 
“plug and play" in thousands of comput¬ 
ers, PDAs, handheld data-collection ter¬ 
minals, and cellular phones. 

Incompatibilities between various FFS 
and FTL products have been resolved by 
companies producing flash cards dial meet 
the PC Card ATA Standard. 

Santa Clara, California 

whole DDJ, but I always take time to read 
Michael Swaine’s "Programming Para¬ 
digms," as well as his (c)musings on die 
last page—"Swaine’s Flames." Mostly I 

find his reflections well founded, although 
I may not always agree. However, when 
we disagree cm such a fundamental issue 

to express my concern. “Light” in this re¬ 
spect should not primarily be associated 
with efficient programming related to bytes 
or machine cycles as Michael states in 
“Programming Paradigms" (DDJ, March 
1995), but rather to a minimalistic ap¬ 
proach to functionality. Maybe the idea 
behind Occam’s razor best expresses my 
thoughts, with featuritis as its antithesis. 
A small, fast-running program is very of- 



; Dobb’sJournal, July . 









Build, Deploy, Adapt, Scale, Reuse 

With Galaxy, you build, deploy, adapt, scale, and then teuse your 
investment across projects. Your team leverayes Galaxy's world-class 
object frameworks to rapidly create scalable internationalized applica¬ 
tions in C or C** that run across all major platforms. And when you hit 
that unexpected business or technology curve in the road, you won’t 
"bit the wall* with Galaxy. Evolve your applications to a client/server or 
multi-tier distributed aichitecture-when and if your business demands. 

Maximize Productivity Across the lifecycle 

Galaxy offers the highest level of productivity available across the 
application lifecycle. Galaxy's object libraries and innovative structural 
foundations are integrated with the industry's most advanced distributed 
services and GUI builder to maximize your productivity, and your 
flexibility. With Galaxy, your entire application is completely portable- 
no code changes and no compromises. 

Succeed in the Real World 

Hundreds of leading corporations have used Galaxy and our expert 
consulting services to break the vicious application cycle and deliver 
strategic applications on time and under budget. So can you. 

Call 8 OO. 832.8668 today for more information. Ask for the White 
Paper: Building AppUcations that Support Rapid Business diaitjc. 

from Huiwitr Consulting and a schedule of Galaxy seminars. 




11440 fauMrct Park Dnvi 

R«to..VA 22091 MOi32i6W/WI Pie* 703.75l.82M/kM.* 






Seeing (double) is believing 

Dennis Cronin 

T hree-dimensional illusions are showing up in eveiything from 
magazine advertisements to the comic pages of daily news¬ 
papers. Although appearing to be nothing more than a ran¬ 
dom field of dots or wavy patterns, striking 3-D images emerge 
when you "correctly" view the designs. Once you learn to get a 
fix on an image (and almost everyone can), you can look around 
the virtual 3-D image just like looking out a window. Figure 1 is 
a typical stereogram in which the word “SONY" appears, if you 
haven't been able to pick the images out, understanding the con¬ 
cept behind litem may help you experience the illusion. 

In this article, 111 discuss how the illusion works and the origins 
of the technique. Ill also examine the basic algorithm for gen¬ 
erating the images and present a sample program (available elec¬ 
tronically; see "Availability," page 3) that lets you display 3-D 
images on your PC screen. You’ll then be able to quickly design 
and generate your own custom 3-D illusions using a standard 
PC paint program. 

A 3-D Backgrounder 

The terms "single-image stereogram” and "autostereogram" re¬ 
fer to a 3-D illusion composed of only one image and requiring 
no special viewing apparatus. Ollier types of stereograms use 
two small, side-by-side images or require special glasses or other 

'rile most basic single-image stereogram is the single-image, 
random-dot stereogram (SIRDS), which looks like a field of ran¬ 
dom dots with no apparent texture or pattern. In its simplest 
form, the image is composed only of black and white dots, yet 
a vivid 3-D image is clearly visible when viewed correctly. Com¬ 
mercial 3-D illusion posters lake SIRDS a step further, replacing 
the TV-not-tuned-in dot field with a more visually appealing 
texture or repeated pattern. Nevertheless, the principle behind 

Dennis unites drivers for Central Data 's scsiTermlnal Servers, lie 
can be contacted at 

The current crop of 3-D illusions has its tools in basic vision 
research. Bela Julesz is generally credited with being the first to 
use computer-generated, random-dot images to create a sense 
of depth. In his early-1960s depth-perception studies, Julesz 
used |»irs of random-dot images to demonstrate that a sense 
of depth could be achieved with no oilier visual cues. Christo¬ 
pher Tyler and Maureen Clark, in turn, arc generally credited 
for combining two images into a single, random-dot image cir¬ 
ca 1990, creating the forerunner of today s gift-shop rage. 

Since then, numerous companies and individuals have ad¬ 
vanced the art with clever posters, books, and online images of 
auiostereograms. The newsgroup alt.3d, for instance, carries a 
steady discussion of SIRDS-rclated issues, and the FTP site is probably the most active central clearing house 
of autostereograms, information, and programs (see the direc¬ 
tory /pub/stereograms). 

Moking a Point 

To understand how single-image stereograms work, I'll first ex¬ 
amine the most fundamental case of how you make a single dot 
appear at some point out in virtual 3-D space. 

Assume that you want to make point A appear somewhere 
off in the distance beyond the plane of the paper (or screen). 
Imagine for a minute that the image is transparent; your eyes 
will have to convetge (or triangulate) to view point A off be¬ 
yond the plane of the image. Note the points where die rays 
from each eye intersect the plane of die image; see Figure 2. 
By placing a pair of dots at exactiy those locations, you can im¬ 
ply die first point in the 3-D landscape. 

It's not easy to get much feeling of depdi from setting up just 

cues to help it interpret those two lonely dots as a magic point 
in deep space. Tire effect doesn’t kick in until you start to build 
a larger set of information for your brain to cue from. 

Now let's see what happens if you want to make a dot ap¬ 
pear somewhere further away than point A. Referring again to 
Figure 2. notice which rays converge at point B and where they 
cross die image plane. They are slighdy farther apart than the 
two points identified for point A. 

With some basic geometry, you can fonnulate die distance of 
that virtual point as a function of dot separation; see Example 
1. Figure 3 shows the basic convergence diagram again, but with 
the parameters in Example 1 indicated. To give a convincing 

Dr. Dobbs Journal. July . 

Figure 1: Typical stereogran 

urtesy of NVtston Gntfix and Sony Corp.). 

illusion of depth, you luvc to build a complete system of dots 
that map out a 3-D scene. In doing so, you will be able to use 
the formula in Example 1 to map out a system of dot pairs such 
that a complete 3*D scene will be visible to the unaided eye. 

Getting the Effect 

As you stare at a stereogram, you shift the o «m 
eyes and let your focus wander. When you triangulate on a nor¬ 
mal object, your brain tends to select a focal length that will close¬ 
ly match the distance implied by your eyes’ convergence. 

To see a stereogram, you need to break focal length away 
from triangulation. When you find the exact point of triangula¬ 
tion that makes the dot pairs overlap, a portion of tire 3-D inl¬ 
and starts to note this image appearing, it will attempt to adjust 
focus to cause the image to solidify. For some people, this sep¬ 
aration of triangulation and focus comes quite easily; others have 

naturally lire brain adjusts its vision machinery to this new set 
of rules. With a little practice, you can effortlessly maintain a 
good lock on tire image as you look around in it. The effect for 
most people is exhilarating— some of the fun comes from just 
seeing the image appear, and some of it comes from the strange, 
unnatural feeling of having your eyes operating in a way they're 

Making the Scene 

Rendering a scene is a three-step process: 

1. Develop a 2-D depth map of the scene to be displayed. 

2. Process the depth map and build a map of dot-pair constraints. 

3. Assign colors such that the constraints are met. 

In Step *1, you scan the scene you want to render, devel¬ 
oping a depth map of Z values for every- point in the scene at 
the desired resolution. There are various ways to accomplish 
this, but this simple approach suffices: Imagine a line perpen¬ 
dicular to the scene scanning the scene side-to-side and top- 
to-bottom. You take a perpendicular-depth reading for every 
point and record that in your depth map. While this technique 
ignores some basic tenets of real 3-D geometry, it is more than 
adequate for generating these illusions. 

Depth maps can also be generated which are not based on 
any real 3-D scene. I use a paint program to generate a depth 
map using different colors to represent different depths. The test 
program in Listing One (page 92) generates this type of color 
depth map using a simple mathematical formula. 

In Step *2 of the rendering process, you develop a constraint 
map that describes all tire dot pairings necessary to create the 
final image. You don’t describe what color the dot pairs have to 
be, just which ones have to match which other ones. 

A major simplify ing assumption is that humans keep their 
heads oriented vertically with respect to the image. Thus, for 
every point in virtual 3 -D space, you need define only two dots 
along the horizontal axis to imply that virtual point. In fact, if 
you tilt your head slightly when viewing a commercial stereo¬ 
gram. you will quickly lose the image. 

This assumption allows you to break the problem into; 
gle case of rendering one Itorizontal line of the scene at a 
When you have devised an algorithm for rendering a single 

The traditional algorithm for constraint mapping is quite 
pie. An adaptation of it (included in the sample program 
vided electronically) looks like Example 2, where base. 

)r. Dobbs Journal July 1995 

fIf I Mi 

§s|§gggss.rgga ase^llS 

System Architect. The Fast, Affordable Route 
To Client/Server Development. 

Build multi-megabyte DOS programs 
easily, in 16 or 32 bits. 

Here are two great solutions to your DOS 
memory crunch: TOT DOS-Extender® 
for up to 4 gigabytes in 32 bits, and 
286IDOS-Extender~ for as much as 16 
megabytes in 16 bus. Finally your programs 
can access all the memory in a PC. 

Choose TNT DOS-Extender if you want 
ultimate 32-bit power and speed. The fiat 
memory model also makes it simple to port 
horn UNIX. Or, to boost memory in your 
16-bit application, use 286IDOS-Extender. 
Either way, you get the most trusted, most 
widely-used DOS-Extender? in the world. 

Favorite tools. 

.Ml Phar Lap DOS-Extcndcrs work with 
Microsoft and Borland C/C+ + compilers. 
For 32-bit development, you can also 
choose MetaWare, Symantec, or Watcom. 
Keep using CodeView or Hirbo Debugger, 
and all your run-time libraries, including 
graphics. Nobody else gives you this 

DOS into a true 32-bit operating 
I system with a flat. 32-bit address 
u'll build smaller, faster pro- 
id dramatically improve the per- 

prompt. All they see is the power they 
never got under conventional DOS. And 
because Phar Lap products support the 
XMS, VCPI, and DPMI industry standards, 
your applications run under DOS, Windows 
(3.1 and NT), OS/2, and even Windows 95. 

Adds Windows GUI, too. 

□ With the TOT DOS-Extender, you 
can turn a DOS application into a 
Windows application. Our exclu¬ 
sive Win Pipe technology lets you retrofit 
existing DOS applications with a Windows 
front-end. And, unlike Windows programs, 
your applications will run wherever you 

formancc of math-intensive applicauons. 

Get advanced features like multitasking, 
DLLs, and threads. 


Because you embed a Phar Up DOS- 
Extender into your program, there’s nothing 
special for end-users to type at the DOS 

Fully proven. 

Phar Lap DOS-Extcnders arc the leading 
DOS memory solution, in use in thousands 
of products including Visual C++ by 
Microsoft and AutoCAD by Autodesk. Call 
today and find out how you can push die 
limits of your applications w ith Phar Up 

^JrPhar Lap Software, Inc. 

60 Aberdeen Avenue. Cambridge. MA 02138 617-661-1510 FAX: 617-876-2972 


Table 2: Setting up the palette. 

(continued from page 24) 

The wiggles parameter can be anything in the range 0-500 and 
only takes effect when the horizontal parameter is greater than 
1. If wiggles is 0, the horizontal runs all drift right; if niggles is 
greater than 480, the horizontal runs all drift left; in all other cas¬ 
es, the horizontal drifts reverse direction every line. 

In sprite mode, the parameter’s functions are somewhat dif¬ 
ferent. The horizontal parameter determines the maximum 
amount of horizontal waviness that can be injected into the sprite 
mapping. The vertical parameter can be: -1, where wiggles start 
at top of screen and decrease toward bottom; 0, where wiggle 
depth is constant top to bottom; and 1, where wiggle depth in¬ 
creases toward the bottom of the screen. The wiggles parameter 
controls the wiggle frequency, as in the texturing mode. 

While the limited depth resolution resulting from the use of 
a 16-color PCX image as a depth map is restrictive, clever scene 
design can still result in striking stereograms. 

The Egg-Carton Test 

Listing One is EGGCARTN.C, a test program. Compiling this pro¬ 
gram lets you see stereograms without editing a depth-map 
yourself. The program generates an example PCX depth-map 
file called “EGGCARTN.PCX. ” Invoking the program with an op¬ 
tional command-line parameter 0-15 causes it to generate differ¬ 
ent surfaces of varying degrees of interest. 

In DOS mode, you should first run the test program to gen¬ 
erate the PCX depth map (type EGGCARTN and press Enter). 
Next run the stereogram program to view the results by entering 
3D EGGCARTN.PCX. You should be able to see a repeating con¬ 
tour not unlike that of an egg canon. 


Many areas of single-image-stereogram generation are still be¬ 
ing explored. An example is “shimmering,’ which involves ren¬ 
dering the image several different ways, then rapidly flipping 
the graphics page between the different images. The image ap¬ 
pears very solidly, but has a shimmering quality. Some people 
find the images easier to view this way. Shimmering paves the 
way for possible stereogram animation. 

So keep your eyes peeled. That apparently random texture 
on the stone front of a building, the slight shift in the wallpaper 
of your company’s bathroom, the advertisement with the un¬ 
dulating, repeated logo in the background (that one’s real al¬ 
ready)— they all might be carrying secret messages in 3-D. 

i page 92.) 

REGISTER TODAY 1-800-355-9845 

1995 July-December Course Schedule 

>r. Dobbs Journal, July j 

A Ray-Casting 
Engine in C++ 

The Suite Way to Build 
Portable Applications 

I s building applications your 
job? Then life just got easi¬ 
er thanks to the zApp* 
Developer's Suite. The zApp 
Developer's Suite is a set of 
highly integrated C++ devel¬ 
opment tools designed to help 
you transform the blueprints 
in your mind into commercial 
quality applications quick¬ 
ly and easily. And best of all, 
applications built using the 
zApp Developer's Suite are 
portable to fourteen different platforms! 
The zApp Developer’s Suite consists 
of zApp, the award-tvinning portable C++ 
application framework; zApp Factory”, a 
fully visual application designer and code 
generator; and the zApp Interface Pack, a 
collection of high-level visual objects for 
the zApp environment. All of these tools 
are highly integrated to provide maximum 
ease of use and flexibility. 

Rapid Application Development. 

Introducing an exciting new visual 
technology that lets you drag and drop a 
wide assortment of objects like toolbars. 

Object-oriented Power. 

The best news is that this devel¬ 
opment environment sits on top 
of zApp, the industry leading 
C++ application framework, and 
the zApp Interface Pack, so you 
have all of their power at your 
disposal — toolbars, table 

tables, and 3D dialogs; define their 
characteristics; and build interfaces of 
any complexity; all in one powerful but 
easy to use environment. With the click 
of a button, you can engage a powerful 
test mode which lets you interact with 
your application, seeing it exactly like 
your end user will see it: letting you fill 
in dialogs, pull down menus, etc. When 
you are pleased with the look and feel of 
your application, fully commented C++ 
source code is only a mouse click away, 
thanks to the zApp Developer's Suite's 
code generation capabilities. 

all, pver 300 object classes of 
power just waiting to be tomor¬ 
row’s best-selling application. 

Portability and More. 

When you're done building your applica¬ 
tion, then you can decide what platforms 
you want to support! Applications built 
using the zApp Developer's Suite are 
single-source portable to fourteen different 
platforms. By simply recompiling, your 
application will run natively on Windows, 
Win32 (including Windows 95), OS/2*, 
and the leading X/Motif platforms. 

Free Demo. 

Sound impossible? Well, if seeing is 
believing for you, call 1-800-346-6275. 
ask for our free demo disk, and get a 
glimpse of what the future Iras to offer. 

Complete your cross-platform puzzle. 

lb solve your cross-platform puzzle, you need all the 
right pieces. Wind/U ™ 2.0 enables you to create native 
UNIX/Motif applications with the Windows API and Visual 
C+ +. With Wind/U, you can develop and maintain just 
one source code base for the Windows, UNIX, and Windows 
NT versions of your 

Wind/U applications 
maintain identical 
functionality between 
Windows and Motif 
versions since Wind/U 
provides features such 
as PostScript and PCL 

Bristol Technology Inc. 

Bringing the Best of Micro 

printing, DDE, MDI, Palettes, Common Dialogs, Winsock, 
and multi-byte character support You can even use 
your WinHelp files on UNIX with Bristol’s HyperHelp'“. 
Wind/U supports Winl6, Win32, and MFC. 

Superior functionality, native performance, and a 
single Windows API source code base make 
Wind/U the best possible solution for developing 
UNK applications. 

For more information call: (203) 438-0969, 
fax: (203) 438-5013, email:,, URL: http:7Avww.bristol.coin 

wind * 



Suite. Visual 
tools that 
harness the 

productivity ot 
C and C++. 


Figure 5: Assembly-language version of RayXZ() and RayYZO. (a) Using 
16-bit fixed-point math; (b) using 32-bit fixed-point math. 

ontinued from page 32) 

aling factor for texture mapping a wall 
slice. Since the amount of code inside the 
loop is small, more time is spent pro¬ 
cessing the loop code (increments, com¬ 
pares, and jumps) than the code inside 
the loop. In order to unroll the loop, 1 take 
advantage of the fact that the row variable 

perform two additions instead of one for 
the same amount of loop code. The loop 

doing useful work; see Figure 4. Opti¬ 
mizing compilers will attempt to unroll 
such loops, but it's often simpler to do it 

When performance counts, there’s no 
substitute for assembly language. The eas¬ 
iest way to convert a function from C to 
assembler is to use the assembly output 
of the compiler as a starting point. Con¬ 
version to assembly provides three ad¬ 
vantages over compiler-generated code. 
The First is avoiding redundant segment- 
register loads. Segment values rarely 
change, yet most compilers insist on re¬ 
loading segment registers inside loops. 
Another advantage is the ability to keep 
values in registers longer and avoid mem¬ 
ory references. Most compilers use register 

The same addition in 32-bit code requires 
just three instructions and three memory 
operands. Figure 5 illustrates this with 
assembly-language versions of RayXZO 
and RayYZO that use 16- and 32-bit fixed- 

Finally, you can write tighter loops by 
avoiding memory operands and keeping 
everything in registers. Many times, 
however, there are simply not enough 
registers available for this approach. The 
solution is to replace the memory op¬ 
erands with immediate values and change 
the values at run time. All that is need- 

segment override. The hardest part is 
knowing where in the code segment to 

the LST generated by TASM. Write the 
self-modifying code, assemble it, then 
check the .LST File to verify that the code 
is overwriting your dummy value. Note 
that if the modiFicd code follows too 
closely (without an intervening branch) 
you may have to dear the prefetch queue 
using a JMP $+2. This breaks the opti- 

By definition, self-modifying code is dif- 


ith other C/S 

PNG: The Portable 
Network Graphic Format 


Put the pedal to the 
metal and enter Motorola's 
68HC705J1A design contest 
a 1996 Ford Explorer*. 

The contest begins May 15 and ends October 31, 

1995. And entering is easier than you think. 

First, order your 68HC705J1A development kit 
from your local distributor at the low introductoiy 
price of just $99°*! It's packed with the hardware, . 

* to get rolling, 

,ce your 8-bit 

Finally, sit back 
and think about winning. 
Four entrants will each win a family enter- 
And the grand prize winner 
will drive away in a ‘96 Ford Explorer. 

But think fast, because the contest comes 
to an end October 31! The complete development 
kit and entiy form, contest rules and details are 
available only from your local Motorola distributor. 

"They laughed 
when I sat down 
to create my 
UNIX port/ 

from scratch would easily con¬ 
sume eight months, 
and a pile of money. 
Then I discovered 
MainSoft. Their 
MainWin demo 

go from Windows to UNIX with no 

"We visited MainSoft and brought 
along our source code. Less than 8 hours 
later, my editor and GUI were up and run¬ 
ning on UNIX. Today, our product has 

"MainWin also provides a consistent 
environment across the different UNIX 
t took us 2 hours to 
go to HP®. One and ah 
hours to Alpha. And 3 hours 4 
to SGI®. Altogether, we 

effort to support the 
UNIX platforms. 

Which means that with ^ 
minimal extra effort, we’ve 

m Sun®, it took us 2 hours to 
la. hours t/Kk jjj^ 
5% more 

■onthe jreLwal 

s that with 

a effort, we’ve ^ 

markets and made 

But when I had a SUN version just 8 hours later... 


Implementing and 
Using BSP Trees 

? t3-D 

^— §f~ffS | 

Nathan Dwyer 


Not much is free these days except Turning Point’s software development information kit. 
And if your response to any of the following issues is yes, you just might want to get one. 

Pla 1f r yo« Hke what you see in our free information kit, we could be talking a free lunch here. 

HgHI ! T ‘,r n To Turni ng Point! 

Get yourself a copy of BoundsChecker for Windows, DOS, WIN32S, 
Windows NT or Windows 95... at only $249, 
can you afford to be without a winner? 

Call 1-800-4-NU-MECA Today. 


jt’s BoundsChecker Again! 

In the competitive world of software development it's rare to find a 3-time 
winner. This year, Nu-Mega's automatic error detection and analysis tool 
BoundsChecker won its third Jolt Award for Product Excellence. 

The Jolt Award for Product Excellence is given to products that "jolt" the industry with their significance. 
This award is co-sponsored by Jolt Cola, a soft-drink with high caffeine and sugar content known to speed 
up the productivity of programmers working long into the night. 

Win32 Shared Memory 

Whether you're 
headed to Chicago, 
Daytona, or 



JPEG-Like Image 
Compression, Part 1 


The Standard 
For Easy-to-Use 

EZ-RPC For Distributed APIs: 

The Truly Multi-platform RPC 

H * EZ-RPC supports partitioning APIs among 
: heterogeneous platforms and distributing remote 

APIs Irom UNIX to Windows with automatic con- 
I version olC APIs to Windows DLLs 
■ a EZ-RPC integrates distributed applications 
I with industry-standard APIs such as WinSock, 

8 a EZ-RPC's patented memory management algorithms 
allocate and Iree memory (or inherently stable server 
code and to protect against client-side memory 

Orbix For Distributed OBJECTS: 

The Original CORBA-Compliant ORB 

a Orbix includes complete development environment 
for managing multi-platform line-grained objects 
a Orbix includes Implementation Repository and 
advanced administrative tools such as a stream-based 
Dynamic Invocation Interface 
a Orbix provides programmable client-transparent 
proxies for performance improvement 
a Orbix features process-level filters to integrate thread 
packages, monitoring and debugging, auditing and 

a EZ-RPC XDR libraries support passing of complex * 0rblx P ravides ,l " 1 « CORBA1.1 

data structures: only implementation ol ONC RPC standard 

library on Windows 3.1, NT and Macintosh 

Both create portable lightweight middleware that travels 
with the application. There's no need to change or upgrade 
systems when you roll-out applications. NobleNet products 
protect developers from complex network coding, distribute 
C and C++ code, support fast code partitioning for rapid pro¬ 
totyping with tools such as Visual BASIC and PowerBuilder, 
and operate across TCP-IP and IPX/SPX stacks. ONC and 
CORBA compliant. Works on all the key platforms: From 
and to AIX, DG/UX Digital UNIX. HP-UX, Macintosh, 

NetWare, Next, OpenVMS. OS/2, Pyramid, SCO-UNIX, 

SGI. Siemens-Nixdorf, Solaris. Stratus, System V Rev.4. 
Sun/OS, UNIXware. VxWorks. Windows 3.x and Windows NT. 
As clients and servers. 

Call Today For 

No-Obligation Evaluation Copy! 
1 - 800 - 809-8988 


W NobleNet 



If Ever y NetWare. User Paid You $1 

You'd Hove $40 Million. 

You Can Tap in to this Market for 
Only $49.99 

More than 40 million users currently run 
their business applications on NetWare network 
operating systems. That gives NetWare a 70 
percent share of the network market. And it gives 
you a great reason to choose NetWare for your 
development platform. 

To get you started developing to the most 
powerful and popular network operating system— 
NetWare 4.1—we’re offering a complete 
development kit for only $49.99. 

This kit contains: 

• A complete two-user version of NetWare 4.1 

•Complete user documentation for NetWare 4.1 

• A special-edition NetWare 4.1 software 
development kit (SDK) 

The SDK includes: 

- All the APIs you need to develop to NetWare 

- Sample code 

- Complete subroutines 

Order While Our Supply Lasts 

This is a special offer that is limited to our 
current supply. 

In the United States and Canada, call 

In all other locations, call 

Call today. Forty million 
NetWare users can’t wait 
long for your application. 



TheWin32API power guide to application development for 
Windows NTand Windows '" 95! 

Here’s the one-stop resource that will help you build synchronization, virtual memory management, memory- 
powerful and robust applications for Windows NT and mapped files, file I/O, dynamic-link libraries, and structured 

Windows 95. Whether you’re building Win32-based exception handling helps maximize performance and 

applications from scratch or porting existing 16-bit minimize frustrationsJhe accompanying CD-ROM includes 
applications, you get core information, expert advice, more than 25 example programs written in C that show 
and proven techniques. Detailed coverage of Win32 Win32 programming techniques in action, 

threads and preemptive multitasking, thread 

fied for the luminance (brightness) por¬ 
tion of the image data, and another, for 
the chrominance (color). Quantization co¬ 
efficients with values approaching one al¬ 
low the corresponding frequency coeffi¬ 
cient to pass through the quantization 
process unmodified. Large quantization 
coefficients force the corresponding fre¬ 
quency coefficients to approach zero in 
value. Thus, visually insignificant, high- 
frequency information is discarded. 

In the CAL code presented here, you 
can specify a quality factor value in the 
range 10-100, where a value of 10 results 

ticeable image degradation, and a value 
of 100 results in much lower compression 
but with generally unnoticeable image dis¬ 
tortion. The quality factor that you spec¬ 
ify is used to manipulate the quantization 
tables in the JPEG specification. A quali¬ 
ty factor of 100 causes all of the quanti¬ 
zation coefficients to become 1, resulting 
in no quantization (any number divided 
1 is still that number). A quality factor 
50 causes the quantization tables in the 
specification to be used unaltered. Qual¬ 
ity factors approaching 10 result in large 
quantization coefficients, which causes 
many of the frequency coefficients to be 
quantized to 0. As more and more of the 

frequency coefficients become 0, the more 
an image can be compressed. 

During quantization, the image data is 
divided by die values in die quantization 
table, but during JPEG decoding, image 
data must be dequantized. Dequantization 
is performed by multiplying the decoded 
image data by the value in the quantiza¬ 
tion table, thereby restoring it to a value 
close to the prequantization value. 

Entropy Encoding 

The final step in the JPEG encoding pro¬ 
cess is entropy encoding. The JPEG spec¬ 
ification allows for either arithmetic or 
Huffman encoding. It is generally ac¬ 
knowledged that arithmetic encoding per- 

but is much more complex to implement. 
Also, diere are currently patent problems 
with using arithmetic encoding, so most 
implementors steer clear of it. Huffman 
encoding is in die public domain and can 
be used without worry of patent infringe¬ 
ment. Consequently, Huffman encoding 
is utilized in most JPEG implementations 
and in the CAL code. 

Using Huffman encoding as the en¬ 
tropy-coding mechanism provides addi¬ 
tional lossless compression for the already 
highly processed image data. Huffman 

compression is based upon the statistical 

pressed: Symbols that occur frequently in 
the data are assigned shorter Huffman 
codes; those that occur infrequently are 
assigned longer codes. Compression will 
occur as long as there is a large difference 
between the occurrence counts of the 
most common and the least common sym¬ 
bols. Note also that Huffman coding is bit 
oriented, not byte oriented. Tlic Huffman 
codes assigned to the various symbols are 
bit packed together into the tightest pos¬ 
sible configuration of bytes. This makes 
the code for I luffman encoding/decoding 
difficult to write and debug because the 
data stream has to be examined at the bit 
level. Convenient byte boundaries do not 
exist at the lowest level. 

During the encoding process, the JPEG 
frequency coefficients for a block of im¬ 
age data are bit encoded as a variable- 
length Huffman code, followed by a vari¬ 
able-length integer. During decoding, the 
variable-length codes and accompanying 
variable-length integers ate converted back 
into integer values for subsequent pro- 

Two additional forms of data com¬ 
pression occur in tlie entropy-coding step: 
della coding of tlie DC coefficients of ad- 

Smooth, flicker-free, sprite-based animation for multimedia — 
without specialized hardware! 

Discover practical secrets for creating full-animation 
scenes—complete with sound—using the 32-bit tools 
in Microsoft® Visual C++™ version 1.1. Streamline the 
process of creating a graphics engine by using the 
Microsoft foundation Classes (MFC) to take care of the 
tasks all Windows-based applications have in 
common.Then derive from MFC dassesa set of 


C++ classes to implement an animation engine. 
Using the static-link library built from the C++ 
classes on the accompanying CD-ROM, you can 
easily apply what you've learned to your own 
multimedia applications. 

Microsoft Press 


Download Oracle Workoroup/2000 off the Internet and try it 

We'd like to expose you to the next-generation 
of pc client/server computing. For free. 
(See bottomline for details.) 

Copy Protection 

* PARAf/ock makes you mosey 


* PARAf/ock i« aggressively priced 

* MACf/ock works on Macs* Power PC’s 

* NETffock provides LAN license control 

* Broad Product Range 

Spending $25+ for copy protection should get you more than a pretty dongle. 
Please let us explain why PARAl/ock's micro processor is superior to old 
fashioned ASIC technology. Call us TODAY and order your Developer API. 
We will also send a kit to get you started on filing your copyright application. 


800 - 909-3141 

On CompuServe GO PIRACY 

Call TODAY & Receive a FREE Copyright Filing Kit 

CAll TOLL FREE at 1-800-850-575510 get your FREE-DEM0. 
ASK aPout out new OompeiiilVB Upgrade Plan. 

CAL uses 2-D 4:2:2 chroma subsampling, 
which seems to be an acceptable trade¬ 
off between image quality and compressed 
image size for the photographic-quality 

Each 8x8 block of color-component in¬ 
formation is referred to as a "data block" 
or “data unit." TO define a region of an 
image. 2-D 4:2:2 subsampling requires four 
blocks of Y image data for each block of 
Cb and Cr data. These six blocks arc re¬ 
ferred to as a minimum coded unit (MCU). 
Without subsampling, an MCU would con¬ 
sist of one block of Y, one block of Cb, 
and one block of Cr data. For gtay-scale 
images, each block of Y data would be 
considered an MCU. 

Next Month 

Up to this point, IVe discussed the vari¬ 
ous concepts and algorithms utilized in 
JPEG compression. Next month. I'll focus 
on tile CAL implementation of JPEG tech¬ 
nology. In doing so, 111 describe the de¬ 
sign and operation of live C++ classes and 
discuss the practical considerations in im¬ 
plementing DCTs and color-space con¬ 
versions (King only integer arithmetic. Ad¬ 
ditionally. I will provide a series of images 
that show the effects of various levels of 
CAL compression and give some figures 
on CAL performance. 


ISO JPEG Standards (D1S10918-1 and draft 
DIS 10918-2), ANSI Sales (212-642-4900). 

JFIF File Formal Specification, Literature 
Department, C-Cube Microsystems Inc., 
399A West Trimble Road, San Jose, CA 
95131 (406-944-6300). 

Loeffler, C„ A. Ligtenberg, and G. 
Moschytz. "Practical Fast 1-D DCT Algo¬ 
rithms with 11 Multiplications." Proceed¬ 
ing of the International Conference on 

. YiMSTBc 

Pennebaker, William B. and Joan L, 
Mitchell. JPEG SliU Image Data Compres¬ 
sion Standard New York, NY: Van Nos¬ 
trand Reinhold, 1993. 

TIFF 6.0 File Fonnat Specification. Al¬ 
dus Corp. (206-628-6593) and via ftp at ( See the file graph- 

Wallace. Gregory. The JPEG Still Pic¬ 
ture Compression Standard." Communi- 
- s of the ACM (April 1991). 

(Listings begin on page 102.) 

Dr. Dobbs Journal, July 1995 


IjiHjEJJjS filijili jj 

IjjjjLoilJoJ -r^Ya/Lr^ 

Have you been looking for full-featured, cross-development 
tools truly designed for the specific requirements of your 
embedded PowerPC application? - Look no further and 
consider this: 

• C, C++ and F77 highly optimizing compiler suites 
provide you with: 

• Over SO global and local optimizations that 
maximize the PowerPC pipelined architecture. 

- Intelligent defaults that give you optimized code right out of the box. 

- Full C++ implementation including exceptions, templates 
and run-time type information. 

- Code optimization based on program profile for automated 
performance tuning. 

• Support for your embedded environment: 

- Complete control of memory allocation of code and data. 

- Flexible asm macros for inlining of assembly in C or C++ code. 

- Structures can be packed to match typical 68K or other types. 

- A powerful graphical source level debugger that 

• From a reliable vendor committed to your success: 

- Platinum member of Motorola’s embedded developer program. 

- Breaking new ground in CISC and RISC compiler technology 

- Known for our responsiveness and very fast turnaround. 

\ If you are developing embedded applications running on 
| the PowerPC, 68K, or CPU32 families, please contact us 
l for more information: 

: North America Europe 

| Phone:(415) 571-1700 . 

f Fax: (415) 571-9068 

I email: d-veIoper@ddi.coi 

The Future for 
Programmable Logic 

Will tomorrow’s 
industry be PLD based? 

Nick Tredennick 

W illi the invention of the integrated 
circuit, TTL (transistor-transistor 
logic) displaced the transistor in 
embedded-system designs be¬ 
cause Til components increased the de¬ 
signer's efficiency. Similarly, in the 1980s, 
microprocessors began displacing TTL. In 
the coming years, however, microproces¬ 
sors themselves will be displaced by pro¬ 
grammable-logic devices (PLDs) in many 

hardware and software perspective, this 
transition will have significant impact on 
the design and implementation of em- 

prepare for this inevitable change. To de¬ 
termine when this transition will occur, it's 
uselUl to examine the development of tile 
microprocessor itself. 

Figure 1 illustrates the conceptual de¬ 
sign difference between TTL and a micro¬ 
processor. TTL designs use a catalog of 
TO. macro functions. The state sequencer 
and data unit are wired directly into the 

A microprocessor system, on the other 
hand, implements a standard design, such 
as that illustrated on the right side of Fig¬ 
ure 1, and implements the algorithm in a 
program in memory. Figure 2 illustrates 
the conceptual mapping of the applica¬ 
tion into a microprocessor design. Tile al- 

struction set of the microprocessor (it 
wouldn't do to pick an algorithm which 

Nick is chief scientist at Altera and can be 
contacted at 

depended heavily on floating-point in¬ 
structions if the microprocessor didn't im¬ 
plement them). The algorithm is then 
mapped into a high-level language (HLL). 
rile HLL description of the algorithm is 

in the conceptual model of the implemen¬ 
tation. In TO. implementations, the stale 
sequencer and the data unit ate fixed in 
the hardware. This gives low cost and 
excellent performance for a single appli¬ 
cation. In microprocessor implementations, 
the state sequencer is a program driving a 
general-purpose data unit. This gives low- 
cost and adequate performance for a broad 

cess technology have led to a proliferation 
of TTL components. A TTL catalog con¬ 
tains hundreds of pan types (corresponding 
to hard macro functions available to the 
designer). Individual TO-style designs arc 
customized for individual applications. As 
the TTL pans catalog grew, system manu- 

ing variety of TTL components. Those same 
improvements in process technology led to 
the development of the microprocessor. In¬ 
stead of a custom design of selected TO 
pans, the microprocessor design consisted 
of a smaller variety of standard compo¬ 
nents: microprocessor, memory, and I/O 
components. A single, basic design could 
lie used for a large variety of applications 
lay changing the program in memory. Since 
the microprocessor and its associated 
components could be used in a range of 
designs, the microprocessor attained high- 
production volume, leading to low cost— 
a basic requirement for embedded-control 

Embedded Control 

Simple designs, such as those in consumer 
appliances, drive the vast majority of com¬ 
ponent sales. For these designs, problem 
size is small and performance isn't an is¬ 
sue. Cost is the driving issue. Figure 3 il¬ 
lustrates my guess for the position of the 
bubble representing die majority of com- 

problem-size domain. Most of the volume 
in the four-billion-unil microprocessor 
market lies in the overlap between the 
"Zillions of Component Dollars' and the 
"Embedded Microprocessor" bubbles. 

In the zillions-of-component-dollars 
bubble in Figure 5. PLDs compete with 
TTL and microprocessor designs. At the 
very low end of the problem-size and per¬ 
formance scale, process improvements 
benefit PLDs, but TTL devices are stalled 
for cost and performance improvement as 
they become pad limited. Programmable 
logic offers the same performance and 
component cost, but there are fewer com¬ 
ponent types to stock and fewer compo¬ 
nents in the final design. 

As Figure 4 shows, PLDs offer a more- 
direct solution than microprocessors for 

means adreaper, more-reliable design. The 
same process-technology improvements 
driving the expansion of rite embedded- 

Dr. Dobb's Journal, July 1995 


SDK Annotations 

by calling ti 



m % 



TODAY! 913-841-1631 
AX 913-841-2624 


Smashes Bugs 

Tool Solutions 
for Embedded 

SoftProbe is our source-level debugger 
for x86 development. The SoftProbe Remote 
Target Debuggers are designed to debug 16- 
and 32-bit real- and prolected-mode C and C++ 
applications. This is achieved by communicating 
directly with your embedded target system 
via the RS-232 serial port. ROM-F.mulator 
versions of SoftProbe are also available to 
communicate with the target system via the 
ROM socket. 

SSi is the leading supplier of 16- and 32- 
bit embedded development tools. Offering the 

simulators and emulator support available today 

*X86/186/188/286/386/386 EX/486 
and Pentium processors 

•Real-and Protected-Mode 
Program Development 

•Cand full C++ debugging solutions 

•Support for Microsoft, Borland, 
MetaWare and WATCOM 
compilers as well as MASM 

Now a Periscope hardware 
debugger is within every 
developer s reach 

...We’re passing on recent cost 

Dll Periscopes) whn your system kxks up. 

DEBUGGERS for dos, HARDWARE when you 
Windows and OS/2... need the power of an Id... 

_ lsc Periscopc/32 to ... 

level software running under Windows <1 -, 

3.x, Windows 95, OOT 2.x, or vour ■ Rent a full-bit 
own 32-bit operating environment. $350 per month. 

386s and 486s... CALL FOR DETAILS! 

CALL TOLL-FREE 800/722-7006 


Dr. Dobbs Journal, July. 

The most powerful force in embedded development! 

V/TY cm*- It’s a development tool mine field out there. Don't go if alone. 
Team Paradigm has the tools, experience and vision to blast through the haze and lead 
you to a victorious conclusion of your 80x86 embedded system design. 

HTtHSCHfifiCe- Armed with the most comprehensive software development 
tools supporting the latest Borland/Microsoft C/C++ compilers, the hottest new Intel and 
AMD microprocessors, the most powerful in-circuit emulators... Team Paradigm alone 
can fill your development tool arsenal. 

COr/TROt- Use Paradigm LOCATE to prepare your Borland Cm or Microsoft C/C++ 
application for the rigors of an embedded system without resorting to dangerous shortcuts. 
Choose a version of Paradigm DEBUG to search out and destroy those killer bugs standing 
between you and glory. 

Settle for less than the best and suffer the consequences. Give Team Paradigm a call 
and let the Doctor, Kat and Lync help you whip your design into shape. 


Proven Solutions for Embedded C/C** Developers 

1 - 800 - 537-5043 

Paradigm Systems 
3301 Country Club Road. Suite 2214 

(607) 748-5966 
FAX: (607) 748-5968 



0b Sofaue/ifa, 

The fastest way to develop 
real-time embedded software. 

4 Instnmionta 

teammates work Control of prototypes 

together more efficiently ^ and logic analyzers 

than ever before. ^ aits your trips to the lab. 

Now rather than trying to "" Our Ultra-Deep Acquisition 

decipher assembly code, you can I Memory - up to 8 MB per channel - 


An Architecture for 
Network Simulation 

A flexible system based 
on a blocks language 

(continuedfrom page 70) her pack® preference them by array with FIFO as Uk default Implementing the 



“Sarnie'l^he packet s smteture. 

14 i- 

m_w > .=t , \ ^CD- 


Graphical Eiffel for Windows! 

User Interface Design and 
Rapid Visual Development 


<c, 4 

Examining the VESA VBE 2.0 

Extending the VESA standard 
Brad Haakenson 



Dr. Dobb’s 
and save 




Enter my one-year subscription to Dr. Dobb’s 
Journal. I get a full year’s worth (12 issues) for only $25.1 save 

- that’s like getting 5 issues FREE! 





P.O.BOX 52226 
BOULDER, CO 80323-2226 




P.O.BOX 52226 
BOULDER, CO 80323-2226 



47 % 









T. Dobb's Journal, July 1995 


Software Development ‘95 East 

October 2-6,1995 Washington, D.C. 

Your Mind is Your Livelihood. Feed it at SD'95. 

Software Development ’95 is the 
most important event of the 
year for cutting-edge develop¬ 
ment professionals. 

Interact with 10.000 of your 
peers and condense months of 
research and learning into a few 
short days. Over 150 lectures, 
workshops and tutorials featur¬ 
ing the industry's leading 
experts cover today's most 
relevant development topics: 

> Team Managers and • Enterprise Application 

Management Re-Development 

• Managing for Quality 
and Productivity 


• Windows 95/NT 

• III Design 

• Building a Software 
Component Strategy 

• Testing and Debugging 

• Client/Server 
Architectures and 

• Database 
and Design 

• Object-Oriented 

• Building Open 4 
Distributed Systems 

Also see over 300 development 
loots from over 200 leading 
vendors and have your lough 
questions answered by the 
product experts. 

Contact us today for the 

productivity, enhance the quality 
of your software, and feed your 
mind at SD '95. 

Software Development 



Windows Programming 

5 Intensive Training Days 

Bruce Eckel 

C++ Fundamentals 

■ Learn today’s premiere programming language 
from one of its most experienced teachers 

■ New! 4-hour C++ lab 

■ Move from C to C++ in just 2 days 

■ Prepare for Windows-based programming with 
C++ and Application Frameworks 

■ Not compiler-specific; suitable for any 
programming platform 

■ Understand polymorphism, templates and 
exception handling 

■ Leant C++ design guidelines 

■ Course book is Bruce Eckel’s 
Thinking in C++ (Prentice-Hall, 1995) 

Programming for Windows with 

Visual C++ & MFC ■ Explore the MFC architecture 

■ Leam visual programming techniques, using Visual " Utilize MFC to get a jump-start on OLE 2.0 

C++ and MFC ■ Leam to build OLE 2.0 object containers 

■ New! 4-hour Windows programming lab and ser,ets 

■ Lean, to use Visual C++ and MFC for Rapid " D,scover " ondcr of 0L£ 2 ’° A “" 

Application Development ■ Leam the fundamentals of OLE Controls 

(415) 905-2784 

Get more 



Choose a city near you! 


_l Seattle July 24-28 

□ Ann Arbor July 31-Aug. 4 

□ New York August 14-18 

□ Portland Sept. I $-22 

□ Austin Oct. 30-Nov. 3 

□ Denver Nov. 6-10 

□ Yes! Send me more information about 
the Software Development Training series 
on C++ and Windows Programming. 


Programming with 

3-D graphics for Windows NT 
Ron Fosner 

I f you’ve worked with the Windows 
GDI, you’re painfully aware of its lim¬ 
itations, particularly when trying to cre¬ 
ate anything other than a flat, 2-D, stat¬ 
ic scene. And whether you program games 
or business graphics, you know that in 
Windows, attempting to create any effects 
beyond a simple gradient fill usually means 
some complicated programming. Recog¬ 
nizing these shortcomings, Microsoft has 
added to Windows NT 35 (and promised 
for all Microsoft 32-bit operating systems) 
a graphics library called "OpenGL,” which 
provides the advanced 3-D rendering and 
animation that is difficult to do with GDI. 

OpenGL is a computer-industry stan¬ 
dard based upon Silicon Graphics’ inter¬ 
nal graphics library. OpenGL was designed 
and is maintained by an industry-wide 
review board composed of SGI, Microsoft, 
IBM, Intel, and DEC. Until recently, Open¬ 
GL was usually found only on UNIX work¬ 
stations. However, with the availability of 
a standardized (and well-known) inter¬ 
face for 3-D graphics, along with advances 
in dedicated 3-D rendering hardware, it’s 
possible to create some amazingly com¬ 
plicated and realistic scenes in Windows 
and render them quickly. In this article, 
I’ll provide an overview of OpenGL and 
illustrate how you can start writing your 
own OpenGL programs. 

OpenGL Primitives 

OpenGL provides primitives for points, 
lines, and polygons. Everything you cre- 

library also provides support routines that 

Ron is a principal software developer at 
Lotus Development, where he researches 
and develops graphical and interactive 
techniques for data analysis and explo¬ 
ration. Ron can be contacted at rort&lo- 

draw curves, surfaces, or text; you can 
also create filled polygons (thereby cre- 

scene out of primitives, you can specify 
lighting effects, specialized effects (fog or 
transparency), and viewing angle. OpenGL 
takes care of the rest: shading, hidden- 
surface removal, and perspective render¬ 
ing. If you don’t like the viewpoint, sim¬ 
ply change it and OpenGL will recalculate 

jects are created, you can dynamically al¬ 
ter their location and rotation, your view¬ 
point, the lighting effects, shading, and so 
on; these, too, will be recalculated for you. 
The hard part is locating and describing 
the objects themselves. 

OpenGL is designed to run efficiently 
as a state machine in a client/server nxxl- 

you might have one powerful computer 
generating the drawing commands (the 
server), while a networked client work¬ 
station receives these commands and does 
the actual rendering on its screen. While 
there’s nothing in NT 3 5 preventing you 
from creating such a program using 
remote-procedure calls (RPCs), OpenGL 
works just as well if the same computer 
is both client and server. Again, the tricky 
part is teaming how to create an OpenGL 
scene and trying to interface between 
OpenGL and Windows, since OpenGL (as 
a hardware-independent library) knows 
nothing about Windows, device contexts, 

OpenGL Libraries 

Three libraries are provided with the NT 
version of OpenGL, the main one being 
openg!32.1ib. By convention, functions in 
this library (such as glDrawPixelsO) use 
the prefix "gl”. Next is the OpenGL utili¬ 
ty library, glu32.lib, containing functions 
such as gluBeginPol)gon(), which use the 

prefix “ghT. These are helper routines for 
OpenGL that provide services such as cre¬ 
ating a sphere, performing matrix manip¬ 
ulations, and tessellation. If you think of 
openg!32.lib as the workhorse of OpenGL, 
then the utility library provides higher- 
level functionality. The final library is the 
auxiliary library written for the OpenGL 
Programming Guide Routines in this li- 

InitWindowO. These functions are not 
strictly part of OpenGL, and needn’t be 
included for most OpenGL programs. 
However, you will likely find them in most 
OpenGL implementations, including NTs. 
I’ll use the auxiliary library, since it allows 
you to ignore the Windows-specific por¬ 
tions of a program and concentrate on the 
OpenGL parts. 

Finally, six new, implementation-specific 
interface routines allow OpenGL to work 
on a Windows platform. Interface routines 
like tvglGetCurrenlContextO use a "wgl" 
prefix and are referred to as “wiggle" rou¬ 
tines. These routines provide the interface 
l)ctween straight OpenGL and Windows 
and are analogous to the "glx" interface 
functions (X Windows’ interface for Open¬ 
GL) in an X Window System implemen- 

In addition, four Win32 functions allow 
access to the pixel formats. These are im¬ 
portant since you have to try to match 
your program's needs with your system’s 
hardware. Finally, there’s one Win32 func¬ 
tion that deals with sw apping the buffers 
in a double-buffered window. 

Watch the Bouncing Ball 

Listing One (page 106) is an OpenGL pro¬ 
gram that displays a bouncing ball on a 
checkerboard surface; see Figure 1. I’m us¬ 
ing the auxiliary library, which lets me ig¬ 
nore Wmdcws and concentrate on OpenGL 
It also lets me write nxxe-traditional C code 

Dr. Dobbs Journal, July 1995 

Port To Tm PomR OT/Ulemo- 

s Painless 32-bit multitasking J 


The Wait Is Over! SEtelfe 

liness that accompanies writing for the 
Windows API. plus the additional worries 
of an OpenGL Windows app. 

Creating and Viewing a 3-D Object 

The biggest change that comes from ren¬ 
dering a 3-D scene is learning how to 
specify both object and a viewing volume. 
In the 2-D worid. you could just specify 
a line to be drawn from, say. 100.100 to 
200,300. and tlrcre it would be, on your 
screen. Things aren't that simple in 3-D, 
because 3-D objects are described by their 
vertices using x-, y-. and z- coordinates. 
The difficulty is compounded by the fact 
that you must specify the coordinates of 
both an object and the viewpoint. 

When a vertex is rendered to the screen, 
it goes through a couple of transformation 
matrices. Figure 2 shows the steps that a 
single point goes through. An object is ini¬ 
tially specified in what's usually called 'ob¬ 
ject’ coordinates, which arc considered lo¬ 
cal for each object. The object is then usually 
translated, rotated, and scaled into “worid" 
coordinates. Objects in worid coordinates 
are positioned with respect to all ocher ob¬ 
jects in the worid. When everything is set, 
all of the viewing and projection calcula¬ 
tions are performed to render your object 
to a collection of pixels on the screen. 

operates. auxResbapeFunc is called when 
the window needs to be reshaped; aux- 
KeyFunCy w hen a specified key is pressed; 
auxIdleFunc, when you have idle time; 
and auxMaittlxxrp is the main loop of tire 

thesefarntiore all hide the Windows mes¬ 
saging system, making OpenGL program¬ 
ming straightforward. Of course, when you 
write an OpenGL program for Windows, 
you have to worry about all the ocher nas- 

Figure 1: An OpenGL program displaying the underside of a checkerboard surface. 


NAVIGATE YOUR WAY WITH BTRIEVE 6. up sol along™ way. 

Now you can avoid dangerous 
waters when you are moving to 
dient/server Btrieve 6 provides 
a safe, direct route while you 

Social structures and distributed 
data routines So you can chart 
the fastest path to your data. 
And you can add SQL applica¬ 
tions at any lime. 


While SQL provides great flexi- 
bilty. it can limit your control 
and performance. Navigational 
dient/server alows you to cus¬ 
tom design relational structures 
and maximize performance 
with directional controls to 
retrieve, update, insert and 
delete distributed data. 

With Btrieve 6. you'll have 
the transaction processing mus¬ 
cle to build mulS-gigabyte data¬ 
base servers supporting hun¬ 
dreds of users with sub-second 
response times. And Btrieve 6 

This way your end-users will be 
working with familiar applica¬ 
tions Vbu’ll avoid the need for 
the massive retraining that 
accompanies a sweeping change 
to new applications an effort 

SQL." our award-winning rela¬ 
tional database. Since both are 
but on our new Microkernel 
Database Engine’ SQL applica¬ 
tions work in unison with Btrieve 
appScations-each having con- 

supports the major server plat¬ 
forms. Netware. Windows NT. 
and OS/2 LAN Server and the 
major client platforms 

Btrieve 6 directional controls 
integrate with existing applica¬ 
tion code so you can seledively 
upgrade your current appSca- 
tions to dient/server. Using your 
3. A and 5CL tods, merely 
replace your data management 
code with Btrieve 6 and couple 
it with the application code. 


(continued from page 88) 

When an object is created, its default 
origin is 0,0,0. Any initial transformations 
to an object are called "modeling trans¬ 
formations." For example, if you create a 
rendering of a car, you'd probably have 

ordinates, and then just^call ,he routine 

matrons that would place the wheels in 
the correct location and orientation about 
the car body in world coordinates. In this 
way, you can create complex objects out 
of simply rendered objects when all of 
the objects are correctly positioned in 
world coordinates, we can specify the 
viewing transformation, Tins will deter¬ 
mine the viewpoint from which we "see" 

As a performance improvement, Open- 
GL combines the modeling transforma¬ 
tions with the viewing transformation since 
the viewing and modeling matrices can 
be combined at this point. What this 
means for the programmer is that the 
viewing transformation is applied firat and 
the modeling transformations follow. This 
is one of the trickier issues about 3-D 
graphics, particularly OpenGL's imple¬ 

Next, the projection matrix is applied 
to take the specified viewing volume and 
clip out everything outside it. along with 
parts of any object obscured by another 
object. The perspective division adjusts 
tile results from tile projection matrix (3-D 
coordinates) and gives you 2-D device co¬ 
ordinates. Finally, these 2-D coordinates 

are mapped to the physical screen by the 
viewport transformation. Fortunately, die 
only complex part of this whole proce¬ 
dure is the specification of the modclview 
matrix and the projection matrix. For now, 
I'll just use a simple set for both. Tile local- 
Reshape function in listing One selects, 
initializes, then sets up die projection so 
that the result is a simple perspective pro¬ 
jection. This is done each time the win¬ 
dow is resized to maintain the correct as¬ 
pect ratio. The localldte function controls 
the modelview matrix, which is selected 
and initialized, and then translates our 
viewpoint along the z-axis. Next, rotations 
are applied along all three axes. In List¬ 
ing One, all these values are controlled 
by the user, so that you can manipulate 

Bouncing Boll Revisited 

The real substance of the Listing One pro¬ 
gram is contained in two areas. The fust 
is the visible part— die program functions 
that render the ball and the surface. The 
functions localDrawSurface and locat- 
DmwSpberv are straightforward. The locol- 
DmwSpbere function simply draws a white 
(glColor3f> solid sphere ( auxSolidSphere ) 
along the y-axis (g ITranslalef). Since 
OpenGI. is a state machine, you must fust 
modify the state (in dtis case, dte color and 
position). Hence, you set the color and po¬ 
sition and then draw a sphere. Note that 
I’ve taken advantage of the aux library 
function to draw a sphere, rather than the 
more-complicated gluSpbere. 

Drawing the surface is similar, except 
that you have to explicidy create the sur¬ 
face out of polygons, and the polygons 
out of vertices. Inskle the two nested for 
loops that divide up llte surface into 
squares, OpenGL primitives are created 
between calls to glllegtn and gWnd (aux- 
SolidSpbere handled this in localDrau- 
Sphere >. This is similar to a WM.PAINT 
message, where you call BegtnPalnt, do 
some painting, then call ISncIPalnt. In the 
case of OpenGL primitives, you signal 
OpenGL that you are going to create an 
object out of some vertices, construct the 
object, then signal you’re done. 

For die localDrawSurface function, the 
glBegln(Gl_QUADS) call tells OpenGI. that 
we are going to construct a four-sided 
polygon (quad). You set die color of a 

Figure 2: The path from 3-D 
coordinate space to screen pixel. 

Visual Basic To Delphi 
Conversion Tool 

Who says you can’t take it with you? 




The Conversion Assistant is a porting expert that lets you painlessly 
ove up to Deiphirthe new visual application development environment 
f he*^nversion'Ass'lsran?reads Visual* Baskfproject and program files 
1 creates the equivalent files that can be read, modified and executed 
iCorwerafon Asslstarrthandles projects of varying size and complexity 

The Conversion Assistant will provide an immediate 
productivity gain for those developers wishing to move to 
Delphi 95. who cannot atfoid to lose any rapid application 

Delphi Conversion Assistant 

Visual Basic Standard Edition $ 79 
• • ual Basic Database Edition $149 

Burlington MA 01803 
Votoe76l7) 273 0308 
Fax (617) 270-4437 

Dr. Dobb'sJournal, July 1995 

IIO *»M_ 




7 , Sff-V.«... 



cise product reviews from over 350 publi¬ 
cations! As a subscriber to Dr. Dobb's 
Journal. Dr. Dobb's Developer Resource i 


John Wiley & Sons 






Rogue Wa i/e 






' VStbsuT '--*“““ : ' u 


.. . 


iSSar - 



' KS. 


i®*— ■■ 



'pl§g w 



^aBsrsraft^r-' sri.*,£*:urs arts •/ 



_ ^SbssssuL. 


s srsass^^asr 

%^;.U4-;;:i t ,.u,.»^,,.w-.. 1 ,: 

sssss, i 

S3 S-S- 

‘ *- sfissssu 3 





: |^r34ffiS=-H , £«sSi«., 

, ::as:ss::: ss 


ras Jtsi^is-r s 

' =if=iss*iiss:: 


“lyu- «... 

K iiSr 


' &5E&KXsr~-”» 

|f [te-- 

| |fca 



*ssdst» n asp-^Tfsrspiaa? 




The Mac, the Web, 
and Errant Pedantry 

that Web pages are, as well as binary files, 
like GIF and JPEG graphics. MacHTTP 
supports AppleScript, so you can integrate 
FileMaker, HyperCard, and SQ1. applica¬ 
tions with your Web pages. Convenient, 
then, that versions of FileMaker. Hyper¬ 
Card. and an SQL application are includ¬ 
ed in the bundle, along with some sam¬ 
ple databases for each and the hooks to 
make them work with MacHTTP. 

For creating and editing HTML docu¬ 
ments, Apple is providing BBcdit, the most 
widely praised code editor for the Mac, 
now featuring a set of HTML-editing 

To see what you've created, you need 
a Web browser. Apple is bundling Net¬ 
Scape from NetScape Communications, 
the company formed by key Mosaic de¬ 
veloper Mark Andreessen and former SGI 
president Jim dark. About NetScape: Both 
the company and the product were ini¬ 
tially overpraised in Use press and are now 
suffering from some backlash. Wired 
magazine (or rather HotWired, its online 
persona) raised an eyebrow when Net¬ 
Scape didn’t have a booth at a recent trade 
show, and the errant pedants on the Web 
object strenuously to certain Web mak¬ 
ers' use of NetScape-only extensions to 
HTML. There's even a Web page devot- 

gard NetScape's blinking text as a big im¬ 
provement over underlining. 

An Aside Regarding Style 

A personal aside that will annoy my pal 
Neil: I recently finished writing a Hyper- 
Card-based HTML editor, and found my¬ 
self using the underline style to flag the 
hypertext links (URLs) in the documents 
that the editor produces. ^ 

derlining early on in the development of 
the product, but I wanted to change it 
right from the start. HyperCard has its 
own mechanisms for supporting hyper- 

that my editor placed in documents ought 
to use some of HyperCard's linking tech¬ 
niques. I implemented that, so the editor 
now assigns the HyperCard Group Text 
style to URLs, rather than the Underline 

Group Text is crucial for hypertext 

URL to a Web browser if you happen 

Maybe that's not clear. The editor pro¬ 
duces documents that a Web browser can 
read. Hie Web browser shows links by its 

preferred style, such as color, and jumps 
to the associated address. I wanted my 
editor to show the links, too, and to in¬ 
voke the Web browser to jump to the 

Talking to the Web browser was easy, 
so the only trick was how to make these 

where to click. HyperCard lias a solution 
for that: By turning on the Show Groups 
property at launch, my editor can use 

The central 
component of 
the server software 
is MacHTTP, 
which IS 
the server 

That convention is (sorry, Neil) under- 

Back to the Bundle 

Of course, HTML could turn out to be a 
flash in tire pan. Some time back, pundit 
Tony Bove expressed the opinion that the 
efforts of Adobe to produce a portable 
document format in Acrobat have been in 

_, - rat the Acrobat 

,e is particularly interesting when 
rublishing over a heterogenous 
til, Apple supplies Acrobat in the 


clickable maps an 

It's interesting that Apple positions these 
as Web servers. That's consistent with Ap¬ 
ple's deep need to be trendy, of course, 
but it also finesses the detail that the soft¬ 
ware bundle isn't all you might want to 
be an Internet provider. 

One missing component is MacDNS, 
the domain-name server software. Al¬ 
though it's promised to ship with the 

servers by summer, it's not in the first 

Apple had its own name-resolution 
problem with this product. Another com¬ 
pany, having had the genius to come up 
with it first, objected to Apple using the 
name MacDNS. The matter has since 
been resolved, and aren't we all relieved. 
Apparently the delay in the release of 
MacDNS was not caused by this non- 

Anothcr missing component: a news 

If Apple delivers MacDNS this summer 
and does something quickly for NNTP 
support, tile missing-pieces issue could 

service providers, coming late to the net, 
will choose to ignore a lot of baggage of 
chiefly historical interest. How many ser¬ 
vices that service providers now provide 

TntP? Definitely gotta have a news 
server, though maybe you can get it else¬ 
where for now. Internet Relay Chap Well, 
okay, but bandwidth allocation is bound 
to be a problem. Same for CU-SceMe. But 
do you really need to put up an Archie 

Here's one view I saw expressed in the 
chat flurry following the announcement 

to the top and only the tried, the true, 
and the downright wickedly cod will sur¬ 
vive. A quintessentially Mac-headed atti- 

Apple Guide Complete 

som here at Stately Swaine Manor drop 
not one but two fat copies of lire aptly ti¬ 
tled Apple Guide Complete (Addison- 
Wesley, 1995). 

Between the covers of this tome are 
500-plus pages and a CD-ROM contain¬ 
ing everything you ever wanted to know 
about designing, building, and scripting 
Apple Guide files, as well as integrating 
them with your applications. 

Always assuming, of course, you are 
interested in knowing anything about Ap¬ 
ple Guide. If you do any Mac program¬ 
ming, you should be, because Guide will 
be a key tool in the next big Mac OS re¬ 
lease (code named "Copeland"), which 
will be hardware independent and is due 

of Copeland, Guide will become a tool 
for developing agents that perform repet- 

Right now, though, Apple Guide is a 
help system that makes it relatively easy 
to produce and deliver on-screen inter¬ 
active help for users of your applications. 
Unlike Apple's Balloon Help, which gen¬ 
erally answers the question "What does 

Dr. Dobbs Journal, July 1995 


' S CD 

O M L 

R A R Y 

You're already a Doha's reader. 
Nowje a Dobbs Super-User. 



PHONE ORDERS: 800-992-0549 




MAIL ORDERS: Dr. Dobb's/CD, P.O. Box 1525, Martinez, CA 94553-9802 


D R . 



Use is 
order form 
lor ell lour 


Rush me die CD-ROMs I've checked off below. I understand that I have a Mi money-la* gm 

D R . 



Glimpse the future of You can't get more 
operating systems. graphic than this. 

386BSD also delivers C and O* libraries, XI1R5 and XI1R6, look 
and utilities, and several popular application packages, There are oter 
575 Mbytes of source, binaries, and documentation. 

Probe the details of a real operating system. Plan for the new technolo- 
your education and see the future of operating systems... todayl 

' S C D - R O 

L I B R A R 

Yon can't get mnre 
graphic than is. 

Essential Books on Graphics Programming CD-ROM 



MAIL OtfflffiS: Dp. Dota's/CD, P.O. Box 1525, Martinez, CA 94553-9802 



CD-ROMs, Classes, and GTIs 
(Graphically Tattooed Individuals) 

Al Stevens 

y P G ntforCIC++ 

presents Bug # 564 



PC-lintfor C/C++ $239 


shrouded C source Poem. Call for pricin 

Glmpell S®twnr<§ 

lot One More Damn 
Line of Code. Iw 

See How LAYOUT Lets You Build Real Programs Without Writing a Single Line of ( ode. Free. 

PC Week cal led Layouts “sure thing." grams. Youcanevencreatcncwobjects more. Layout even supports pictures as 
We call it a revolution. With over right in Layout, or even re-use existing a data-type! And Layout creates very 
200,000 users, tons of add-ons, and source code. Layout supports DOS efficient programs —they’re fast and 
widespread third-party support, Lay- and Windows, with NT and OS/2 compact.No 150K“HelloWorld”pro- 
out is the only tool that lets you build coming soon, and applications written grams come out of Layout: it doesn't 
DOS or Windows programs by ma- onanyoftheseplatformsareautomati- just spit out pre-canned code like other 
nipulating objects on so-called high- 

screen — without level tools, 

writingcodc. Not just iTySfgjgsfi'i — 

simple programs, but ' ‘‘ '' -£ Tke I IlilBlf Tool 

real, heavy-duty, mis- ^_| J | Layout delivers 

sion-critical applica- gg I■?■"■?!» I f | the future for 

■ions. __ , ♦ =! | $299.95, includ- 

| P—1| _| | | ingeverythingyou 

Ihr True I’ourmf Objrtls jfe&l »«>«« »"»■■■ * . ^ ] «- -II need to build pro- 

Layoutistrulyobject- PBBfaH icaniciJLiii. — I grams; free, un¬ 
oriented, both in the — I limited, technical 

programs it creates, e J^ c * rt ~| || support; and su- 

andin how you use it. 

You start out by ar¬ 
ranging objects in a 
simple diagram, and 
then add more ob- 

- , Free! 

Limit Irwi mow Sum 

objects by combining 

existing ones. You can even run your cally portable to the others — i 
program as you're building it. Data- ing Windows 95 (Chicago), 
entry, database, and report formats are 
all visually designed on-screen. Usual Plfflfr, IlKTPlIiHc PWfinUU 

The programs Layout creates are com- 
MtatUjIlllDfliim pletcly graphical, even under DOS, 

When you’re done, Layout creates real and fUlly support OLE 2.0, DDE, 3D 

•EXE files, or well-structured and effi- buttons, hypertext links, messaging, USA 508-777-2800 FAX 508-777-0180 
cient C/C+t, Pascal, or BASIC pro- creating and using DLLs, and much Email 

Australia 07-855-2333 FAX 07-855-2364 


Energize Your DOS Applications 
with a Windows-Style Interface 

A -e your DOS applications starting 
to show signs of age? If so. it's time 
to do some remodeling. With our new 
C/Windows Toolchest™. you can easily 
create interfaces for your DOS applications 
that are similar to 
Microsoft' Windows™ 

Two simple 
function calls are 
all it takes to create 
movable, resizable 
windows, complete 
with scroll bars and 
other standard 
controls: including 
minimize, maximize, 
restore, and menu 
buttons. A wide 
variety of other 
controls are also 
available; including 

push buttons, radio buttons, and check boxes. 

Of course there is extensive support for 
menus. Create horizontal and vertical menus, 
with or without scroll bars. Arrange menu 
items in a single row or column, or in multiple 
rows and columns. Attach a sub-menu to any 

For collecting user input, you get a 
comprehensive set of functions to manage 

data entry fields. Collect data 01 

entry forms. Use picture clauses to build data 
entry templates. Valid input may be enforced 
automatically, or you can define your own 
input validation functions. 

Handling mouse input is easy. There are 
numerous high level 
mouse functions, 
including one that 
retrieves all mouse 
events and key¬ 
strokes. Mouse 
input is handled 
automatically by 
control buttons, 
menus, and data 
entry fields. Low 
level mouse 
functions are also 
provided just in 
case you need 

In all. the 

C/Windows Toolchest™ contains more than 
250 functions to help you design a state-of- 
the-art user interface. Included are functions 
for implementing context sensitive help, 
keyboard control, and graphics. You also 
receive the complete source code for a 
multi-window Notepad editor that works 
in both text and graphics mode. C/Windows 
Toolchest™ works with C and C++ compilers 
from Mix', Borland*, and Microsoft*. 

The Popularity 

Get your subscription to the NEW 

Dr. Dobb’s Sourcebook Series 

U issues per year — 
each one covering one of the hottest 
topics in software development! 

Subscribe to the Dr. Dobb’s Sourcebook Series and get all six issues 
delivered to pur door. Here in six bi-monthly issues you'll find 
in-depth, focused coverage on some of the most important topics 
in software development. 

You’ll also find new columns on. 

S40vSr. All MMr !ot»gn; MOVwr (W iW) Canadian GST oSm^TTiWs). for «lrv»ry. USta " 11 ' 


If your goals include develop- maintenance costs in one step. 

If It Isn't OpcnUI, It Isn't Mcssage-Based 
And You Might Find Your Program Goals Out Of Reach. 

solution tliat rises to the chal¬ 
lenge. OpenUls message-based 

ser interlace and appli 

OpcnUI has PovvcrORID™ 

ur goals for greatly increased de¬ 

tools and environment. Only 
OpcnUI has everything you need 

ing us to receive our OpcnUI 

Add to this support for all 


30 fooisfl*: 603-598-6877 bfc 

•WL. ire 






2 §s 8 8Ss§ '55§ s 58 '~85 $8 §s8§i ' ’ ' 8 's|5| 88 s ?! GS§| !! S62s 8 |si8 



>r. Dobbs Journal, July 1995 

Dr.DohM i 




P.O. BOX 5215 

PITTSFIELD, MA 01203-9857 









P.O. BOX 5215 

PITTSFIELD, MA 01203-9857 


1 SWiM (OSF/MOTIF) 2.0 for LINUX 1 

Embed Intelligence! 1 

■ Build in intelligent subsystems with the power of H 

■ the ALS Embeddable Prolog Engine™. Combine* 

|g§|r , I 

1 system to creafe intelligent embedded subsystems 1 
1 in your C programs. Call in from C. call out from ■ 

■ ronment and linkable library. No royalties or run- ■ 
l«ime fees. ^ x ,« c r| 

■ ACC Corp., Inc. 1-800-546-7274 1 

ISA Lisp with C and VB 1 

; I.inkLisp™for Windows 1 

mst d 

1 • DLL and VBX callable from C/C++, Visual Basic, etc. 1 
| • Large subset of Common Lisp, extensive API 
| ♦ Great for macro languages, formulas, natural language 1 
| • $249 with no run-time fees. Call for more info today! 1 

I Conscious Computing^ 100 Connecticut Ave NW*Suite 202 1 

I Washington, DC 20008*(202) 483-63S0#Fax (202) 462-9110 1 

1 fJWl »1 

1 ifec 


C^« xpe y | 

wlihOb^cis ■* t- 



• sisrr ^ w " n - 

Play by the rules 

the experts use, 

M SSSr— 

CD-ROM Software 

In Computer Science 


DynaZIP toolkits 

[ ^Con^odQ^'loUU^: 9 ^ 



l»«w =5r 


■ *1“ ft',?*™r^Tm'-^cm^r 1 

DbCAD dev 1.3 DLLs 

Got Heap Bugs? 

1 1"? “Sfas I 


1 %SSs£Ss?£i| 

1 ‘^ME 

1 cL ti 1 


developed any 
great SOFTWARE? 

ta r, K0*1« 




to <SW«MW0 t 

_Alex r/j 

Write Your Own Extended System 

SouroCodeandOxTmenla^ $79.95 
Description (applies to abwe) S5.95 


Books from Inside 
the Walls 

Lou Grinzo and Steve Gallagher 

Windows 95 common controls—image 
lists, tree views, rich-edit controls, toolbars, 
property sheets, he ‘ 

Si* HSU mu 



nued on page 140) 


Where do you find 
75,000 professional 
software developers... 
twice monthly? 


Dr.Dobb’s Software Careers 

Targeted recruitment advertising 
for the professional programmer. 

Call Stephanie Dale today at 

415 - 655-4197 

to reserve your space! 

Of interest 




C, C++ and BASIC programmers, 
now you get much more than 
xBase compatible DBMS power. 

m housands of programmers have 
^already discovered how to get dBASE, 
FoxPro and Clipper database 
compatibility from their favorite 
language and hardware platform. 

For example, one customer has C 
programs running on PC and Sun 
workstations sharing data with con¬ 
currently running FoxPro for Windows 
applications. You sec, CodeBase tech¬ 
nology is simply the best way to add 
multi-user xBase compatible DBMS 
power to C, C++, BASIC, or Pascal. 

You still get high speed & small size 

CodeBase users really appreciate our 

engines which are a Meg or so in size, 
CodeBase S. 1 EXE’s can be as small as 
4SK! You'll also like the spccd-with our 
Intelligent Queries you get the execution 
speed of C plus stunning query 
performance from our smart use of 
available index information. 

Get CodeControls 2.0 FREE 

You get formatted data entry 

Experienced programmers know formatted 
data entry is difficult to program under 
Windows. But with CodeControls. you 
can simply 'Point & Click' to design data 
entry windows for date, numeric, and 
character information- formatted just the 
way you want it. 

You get data-aware controls 

Our custom controls arc data-aware. so 
now you can easily build a scrolling list 
box that's tied to a data file, or look up 
matching combo box cnlrics-cvcn as the 
user types. 

Get CodeReporter 2.0 FREE 

Now use the new Instant Report Hl:anl to create 
a variety of reports-instantfy. 

You get interactive queries, 

networked applications... with 
royalty-free distribution. 

You get instant reports 

Use our new Instant Report Wizard to 
quickly create a wide variety of reports 
in an instant, then easily change them or 
let your end users build their own reports! 

Buy One, 

Get Two FREE. 

Now, fora limited time only, when you 
buy any one of our xBase compatible 
library products: CodeBase, CodeBase**, 
Code Basic or CodePascal (for the 
language of your choice), you'll get 
CodeReporter AND CodeControls 
absolutely FREE. 

To Order Now Call 

You get drag & drop 

We've added drag & drop capabilities to 
CodeReporter, so regardless of whether 
you want data, totals, or text-simply drop 
a report object onto your layout screen. 

403 - 437-2410